package cn.com.header.core.support.web.springmvc.converter;

import cn.com.header.core.support.web.springmvc.AbstractConverter;

import java.time.format.DateTimeFormatter;
import java.time.temporal.Temporal;

/**
 * @author liangzhongqiu789@sina.com
 * @date 2017-05-18
 * @time 12:44
 */
public abstract class StringToLocalSomethingAbstractConverter<T extends Temporal> extends AbstractConverter<T> {

    protected DateTimeFormatter dateTimeFormatter;

    public void setDateTimeFormatter(DateTimeFormatter dateTimeFormatter){
        this.dateTimeFormatter = dateTimeFormatter;
    }

    public DateTimeFormatter getDateTimeFormatter(){
        return dateTimeFormatter;
    }

    public void setPattern(String pattern){
        setDateTimeFormatter(DateTimeFormatter.ofPattern(pattern));
    }

    public String getPattern(){
        return dateTimeFormatter.toString();
    }
}
